/**
*@NameSpace
*/
var  BigData = BigData || {};
/**
*@ajax�������
*/


BigData.formatDay = function(d){
	 return d.replace(/[^0-9]/g ,"");	
};


BigData.Ajax = function(url, dataType, data, async, callback, errorCallback, timeout){
	
     $.ajax({
	     async : async,
         type : "POST",
		 data : data,
         url : url,
         dataType: dataType,
		 timeout : timeout || 10000, 
         success: function(rdata){
    	    callback(rdata);
    	 },
         error : function(rdata){	
 		   if( !!errorCallback ){
			   errorCallback( rdata );
		   }
        }
	 });
};

BigData.hasData = function(rdata){
	
	return (rdata != null && rdata.length > 0);
};


BigData.cloneDeep = function(o){

  if(!o){
	 return null;
  }
  var c = {};
  for(var i in o){

	  if(toString.call(o[i]) === '[object Object]'){
	    c[i] = BigData.cloneDeep(o[i]);
	  }else{
		c[i] = o[i];  
	  }
  }
  return c;

};

BigData.merge = function(a, b){

  if(!b){
	 return a;
  }
  if(!a){
	a = {};
  }
  
  for(var i in b){
	 a[i] = b[i];
  }
  return a;

};
BigData.getRange =(function(){
	
     var units = [1,1.5,2,2.5,5,7.5,10], S = units.length;
     function log(a, b){
        var c = (Math.log(b)) / (Math.log(a));
        return Math.floor(c);
     }
     function getInterval(n){
        n = Math.abs(n);
        var o = log(10, n),v = Math.pow(10,o),t = n / v;
        var index = 0;
        for(var i = 0; i < S;i++){
            if(t <= units[i]){
              index = i;
              break;
            }
         }
         return v * units[index];
     };
              
			  
     return function(s, e, splitnum){
         var I = getInterval((e - s) / splitnum);
         e = s + splitnum * I;
         return {low:s,high:e};
	 }
       
})();

BigData.getRange2 = function(M){

   var range = [5, 10, 20, 50, 80, 100], size = range.length
   for(var i = 0; i < size; i++){
      if(M <= range[i]){
	    return range[i];
	  }
   }
   return M ;
} ;
    
BigData.initSelOpt = function(){
	
  $(".sel-opt").click(function(){
	  $(this).siblings().slideToggle(500);
  });
  $(".sel-list-con>li").click(function(){
	  var T = $(this).parent().siblings(), id = T.prop("id");
      T.text($(this).text());
	  $(this).parent().slideToggle(500);
	  //BigData.notifyUpdate(id);
  });
  
};

BigData.line_option = {
   
   title : {
       
   },
   legend: {
       data : []
   },
   grid:{
       x:50,y2:50
   },
   tooltip: {
	    trigger: 'axis'
	},
   xAxis : [
        {   
		    
		}
    ],
    yAxis : [
        {
        	/*type:"value",
        	scale:true,
        	precision:2,*/
			splitNumber : 9/*,
			boundaryGap:[0.01,0.01],
			splitArea:{show:true}*/
        }
       
    ],
    series : [
        {
            name:'',
            type:'line',
			itemStyle: {        // ��ݼ����Ի�������ʽ
                normal: {
                    color: '#fd7d36'
                 }
			}
            
        }
    ]
};

/**
*@
*@��״ͼ
*两个统计项
*/
BigData.bar_option1 = {
   
   title : {
        text: ''
   },
   legend: {
        data:[]
   },
   grid:{
       x:40,y2:50
   },
   tooltip: {
	    trigger: 'axis'
   },
   xAxis : [
        {   
		    axisLine: {show: false},
            type : 'category'
		}
    ],
    yAxis : [

        {
            type : 'value',
            name : 'cc',
			splitNumber : 10,
            axisLabel : {
                color: 'blue'				
			},
			axisLine:{
			  show:false,
			  textStyle : {
                  color : 'rgba(30,144,255,0.8)',
                  fontFamily : '΢���ź�',
                  fontSize : 30,
                  fontWeight : 'bolder'
               }
			
			}

        },
        {
            type : 'value',
            name : 'cc',
			splitNumber : 10,
            axisLabel : {
                color: 'blue'
			},
			axisLine:{
			  show:true,
			  textStyle : {
                  color : 'rgba(30,144,255,0.8)',
                  fontFamily : '΢���ź�',
                  fontSize : 30,
                  fontWeight : 'bolder'
               }
			
			}
        }

    ],
    series : [
        {
            name:'',
            type:'bar',
			itemStyle: {       
                normal: {
                    color: '#fd7d36',
					barBorderRadius: 5
                 }
			}
            
        },
        {
            name:'',
            type:'line',
			yAxisIndex:1
            
        }
    ]
};
/***
 * 一个统计项
 */
BigData.bar_option2 = {
		
		title : {
			text: ''
		},
		legend: {
			data:[]
		},
		grid:{
			x:40,y2:50
		},
		tooltip: {
			trigger: 'axis'
		},
		xAxis : [
		         {   
		        	 axisLine: {show: false},
		        	 type : 'category'
		         }
		         ],
		         yAxis : [
		                  
		                  {
		                	  type : 'value',
		                	  name : 'cc',
		                	  splitNumber : 10,
		                	  axisLabel : {
		                		  color: 'blue'				
		                	  },
		                	  axisLine:{
		                		  show:false,
		                		  textStyle : {
		                			  color : 'rgba(30,144,255,0.8)',
		                			  fontFamily : '΢���ź�',
		                			  fontSize : 30,
		                			  fontWeight : 'bolder'
		                		  }
		                	  
		                	  }
		                	  
		                  }
		                  
		                  ],
		                  series : [
		                            {
		                            	name:'',
		                            	type:'bar',
		                            	itemStyle: {       
		                            		normal: {
		                            			color: '#fd7d36',
		                            			barBorderRadius: 5
		                            		}
		                            	}
		                            
		                            }
		                            ]
};
                    
/**
*@��ͼ
*
*/			

BigData.pie_option = {

    tooltip : {
        trigger: 'item',
        formatter: "{a} <br/>{b} : {c} ({d}%)"
    },
    legend: {
        orient : 'horizontal',
        x : 'left',
		textStyle : {
            color : 'rgba(30,144,255,0.8)',
            fontFamily : '΢���ź�',
            fontSize : 15,
            fontWeight : 'bolder'
        }

    },
    calculable : false,
    series : [
        {
            name:'',
            type:'pie',
            radius : '75%',
            center: ['50%', '50%'],
			itemStyle : {
                normal : {
                    label : {
                        position : 'inner',
                        formatter : function (a,b,c,d) {return (d - 0).toFixed(0) + '%'},
                        textStyle : {
                          color : 'white',
                          fontFamily : '΢���ź�',
                          fontSize : 15,
                          fontWeight : 'bolder'
                     }
					},
                    labelLine : {
                        show : false
                    }
                },
                emphasis : {
                    label : {
                        show : true,
                        formatter : "{b}\n{d}%"
                    }
                } 
            }
        }  
    ]
};
   		
BigData.marker1  = {
     value : 0,
	 symbolSize : 20,
     symbol: 'star6',
	 itemStyle: {        
       normal: {
        color: 'yellowgreen'
       }
	}
};  



BigData.initChart = function(id, theme){
	 if(BigData.chart){
		 BigData.chart.dispose();
	 }
	 BigData.chart = echarts.init(document.getElementById(id), theme);	
};

BigData.createChart = function(id, theme){
	 C = echarts.init(document.getElementById(id), theme);	
	 return C;
};


BigData.initPie_option = function(o, data){ 
	
	     var size = data.length, item;
	     o["legend"]["data"] = [];
	     o["series"][0]["data"] = [];
	       
	     for(var i= 0; i < size; i++){
	      item = data[i];
		  o["legend"]["data"].push(item["0"]);
		  o["series"][0]["data"].push({"name":item["0"], "value":item["1"]});
	     }
		 
};

BigData.compactArray = function(a){


	//if(toString.call(a) !== '[object Array]'){
	//   return a;
	//}
	var b = [];
	var size = a.length;
	for(var i = 0; i < size; i++){
	 
	  if(a[i] != null && a[i] != undefined){
	     b.push(a[i]);
	   }
	
	}
	return b;
	
};

BigData.cities =

{
		"广州":0,
		"深圳":1,
		"东莞":2,
		"佛山":3,
		"惠州":4,
		"珠海":5,
		"中山":6,
		"江门":7,
		"汕头":8,
		"湛江":9,
		"揭阳":10,
		"肇庆":11,
		"清远":12,
		"韶关":13,
		"潮州":14,
		"茂名":15,
		"河源":16,
		"汕尾":17,
		"阳江":18,
		"梅州":19,
		"云浮":20,
		"全省":21
};

BigData.initialize2 = function(){
	
	
   
	 $(window).resize(function() {
        $(".chart-container").css("width", $(window).width()-40 + "px");
        $(".chart-container").css("height", $(window).height()-82 + "px");
        $(".chart-container .chart-zoom").css("width", $(window).width()-40 + "px");
        $(".chart-container .chart-zoom").css("height", $(window).height()-255 + "px");
        $(".chart-container .game-tab").css("height", $(window).height()-230 + "px");

     });

	 $(window).resize();
	 
	  
	 
	 
	
};
